$(function()
{
	$(".delete-news").submit(function(e){
		return confirm("WARNING: This action will DELETE this news item!\n\nAre you sure you want to proceed?");
	});

	$("#title.newnewsitem").blur(function(event) {
		$.post("/manager/news/getslug", {
			"str":$(this).val()
		}, function(data)
		{
			$("#slug").val(data.val);
		})
	});

	$("#news-body-editor").ckeditor({
		"removeButtons":"Save"
	});

	$("body").on("click", ".btn.deletenewsimage", function(e)
	{
		e.preventDefault();
		var $this = $(this), $parent = $(this).parents(".imageuploaditem");

		if(confirm("Are you sure you want to delete this image?"))
		{
			$.get($this.data("url"), function()
			{
				$parent.fadeOut("fast", function()
				{
					$(this).remove();
				});
			});
		}
	});

	$(document).bind('drop dragover', function (e) {
		e.preventDefault();
	});

});